@extends('layout.app') @section('content')
<link rel='stylesheet' href='/js/dropzone/dropzone.min.css'/>
<script type="text/javascript" src="/js/dropzone/dropzone.min.js"></script>
<style>
  
</style>
<form action="/files/uploadImg/upload" id="my-dropzone" class="dropzone">
  <div class="dz-message needsclick">
    拖拽或点击上传.<br>
    <span class="note needsclick"></span>
  </div>
  <input type='hidden' value='{{csrf_token()}}' name='_token'/>
</form>

<script>
  Dropzone.options.myDropzone = {
    // acceptedFiles: "image/*",
    paramName : "upload",
    thumbnailWidth : 80,
    thumbnailHeight : 80,
    init: function() {
      this.on("success", function(file, responseText) {
        if(responseText.res == 'success'){
          $(file.previewTemplate).children('.dz-details').children('.dz-size').css('opacity','0');
          $(file.previewTemplate).children('.dz-details').append(responseText.msg);
          $(file.previewTemplate).children('.dz-progress').css('opacity','0');
          $(file.previewTemplate).children('.dz-details').css('opacity','10');
        } else {
          $(file.previewTemplate).children('.dz-details').children('.dz-size').css('opacity','0');
          $(file.previewTemplate).children('.dz-details').append(responseText.msg);
          $(file.previewTemplate).children('.dz-progress').css('opacity','0');
          $(file.previewTemplate).children('.dz-details').css('opacity','10');
          $(file.previewTemplate).children('.dz-success-mark').css('opacity','0');
        }
        
      });
      this.on('error',function(file,err,xhr) {
        this.removeFile(file);
        if(xhr.res) {
          alert(xhr.res);
        } else {
          alert('图片错误');
        };
      })
    }
  };

</script>

@endsection